package com.github.catvod.spider;

import com.github.catvod.bean.Result;
import com.github.catvod.crawler.Spider;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import com.github.catvod.bean.Class;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Util;

import org.jsoup.Jsoup;

/**
 * 电影6080：https://www.6080tv.com/
 */
public class Movie6080 extends Spider {
    private String siteUrl="https://www.6080tv.com";

    private HashMap<String, String> getHeaders() {
        HashMap<String, String> headers = new HashMap<>();
        headers.put("User-Agent", Util.CHROME);
        return headers;
    }

    @Override
    public String homeContent(boolean filter) throws Exception {
        List<Class> classes = new ArrayList<>();
        List<String> typeIds = Arrays.asList(
                "/dianying/",  // 电影
                "/xijupian/",  // 喜剧片
                "/dongzuopian/",  // 动作片
                "/kehuanpian/",  // 科幻片
                "/kongbupian/",  // 恐怖片
                "/juqingpian/",  // 剧情片
                "/zhanzhengpian/",  // 战争片
                "/jilupian/",  // 纪录片
                "/dianshiju/",  // 电视剧
                "/guochanju/",  // 国产剧
                "/gangtaiju/",  // 港台剧
                "/rihanju/",  // 日韩剧
                "/oumeiju/",  // 欧美剧
                "/haiwaiju/",  // 海外剧
                "/zongyi/",  // 综艺
                "/dongman/",  // 动漫
                "/topic/" // 专题
        );
        List<String> typeNames = Arrays.asList(
                "电影",
                "喜剧片",
                "动作片",
                "科幻片",
                "恐怖片",
                "剧情片",
                "战争片",
                "纪录片",
                "电视剧",
                "国产剧",
                "港台剧",
                "日韩剧",
                "欧美剧",
                "海外剧",
                "综艺",
                "动漫",
                "专题"
        );
        for (int i = 0; i < typeIds.size(); i++) {
            classes.add(new Class(typeIds.get(i), typeNames.get(i)));
        }
        return Result.string(classes, new ArrayList<>());
    }

    @Override
    public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
        Jsoup.parse(OkHttp.string(siteUrl + tid + "page/" + pg + "/", getHeaders()));
        return super.categoryContent(tid, pg, filter, extend);
    }
}
